package com.outsourcing.bottle.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.outsourcing.bottle.BasicActivity;
import com.outsourcing.bottle.R;
/**
 * 
 * @author 06peng
 *
 */
public class EditActivity extends BasicActivity implements OnClickListener {

	private ImageView backView;
	private TextView titleView;
	private ImageButton confirmView;
	private EditText editView;
	private String tags;
	
	@Override
	protected void onCreate(Bundle paramBundle) {
		super.onCreate(paramBundle);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.edit);
		
		tags = getIntent().getStringExtra("tags");
		backView = (ImageView) findViewById(R.id.topbar_back);
		backView.setOnClickListener(this);
		titleView = (TextView) findViewById(R.id.topbar_title);
		titleView.setText(getString(R.string.bottle_tags));
		confirmView = (ImageButton) findViewById(R.id.topbar_confirm);
		confirmView.setOnClickListener(this);
		editView = (EditText) findViewById(R.id.edit);
		editView.setText(tags);
	}

	@Override
	public void onClick(View v) {
		if (v == backView) {
			setResult(ThrowBottleSettingActivity.activity_for_result_bottle_tag);
			finish();
		} else if (v == confirmView) {
			Intent intent = new Intent(this, ThrowBottleSettingActivity.class);
			intent.putExtra("tags", editView.getText().toString().trim());
			setResult(RESULT_OK, intent);
			finish();
		}
	}
}
